package com.hzncc.flowable_diboot.job;

import com.diboot.scheduler.annotation.CollectThisJob;
import com.hzncc.flowable_diboot.service.impl.ToDoListServiceImpl;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.scheduling.quartz.QuartzJobBean;

@DisallowConcurrentExecution
@CollectThisJob(
        name = "发送待办通知",
        cron = "0 0 * * * ? "
)
public class TodoJob extends QuartzJobBean implements ApplicationContextAware {
    private ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }


    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        ToDoListServiceImpl bean = applicationContext.getBean(ToDoListServiceImpl.class);
        bean.generateNotification();
    }
}
